//
//  realNameVC.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/21.
//  Copyright © 2018年 金艺社. All rights reserved.
//

#import "realNameVC.h"
#import "realNameCell.h"
#import "realNameModel.h"
#import "travelCertificationCell.h"
#import "realHeadCell.h"
#import "bankItem.h"
@interface realNameVC () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *detialView;
@property (nonatomic, copy) NSMutableArray *cusTomData;
@end

@implementation realNameVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    CGRect frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - TabbarSafeBottomMargin);
    self.detialView = [[UITableView alloc]initWithFrame:frame];
    self.detialView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.detialView.tableFooterView = [UIView new];
    if (@available(iOS 11.0, *)) {
        self.detialView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        //        if (iPhoneX) {
        //            self.detialView.contentInset = UIEdgeInsetsMake(0, 0, 88, 0);
        //        }else {
        //            self.detialView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
        //        }
        //        self.detialView.scrollIndicatorInsets = self.detialView.contentInset;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    self.detialView.delegate = self;
    self.detialView.dataSource = self;
    [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([realNameCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([realNameCell class])];
    [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([travelCertificationCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([travelCertificationCell class])];
     [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([realHeadCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([realHeadCell class])];
    self.detialView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.view addSubview:self.detialView];
}

#pragma mark --- uitableViewDelegate and dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0 || section == 2) {
        return 1;
    }
    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 2) {
        return 65;
    }else if (indexPath.section == 0) {
        return 35;
    }
    return 50;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) return 0;
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 1) {
        realNameCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([realNameCell class])];
        cell.selectionStyle = UIAccessibilityTraitNone;
        if (indexPath.row == 2) {
            bankItem *item = [[bankItem alloc]initWithFrame:cell.content_lab.frame];
            item.headImage.image = [UIImage imageNamed:@"mine_bankCard_BOC_icon"];
            item.title.text = @"中国工商银行";
            item.subtitle.text = @"单笔支付限额5万，单日限额20万";
            [cell.contentView addSubview:item];
        }
        cell.model = self.cusTomData[indexPath.row];
        return cell;
    }else if (indexPath.section == 2) {
        travelCertificationCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([travelCertificationCell class])];
        cell.selectionStyle = UIAccessibilityTraitNone;
        cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, cell.bounds.size.width);
        return cell;
    }
    realHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([realHeadCell class])];
    cell.selectionStyle = UIAccessibilityTraitNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 20)];
    grayView.backgroundColor = [UIColor clearColor];
    return grayView;
}
#define mark --- getter
- (NSMutableArray *)cusTomData {
    if (!_cusTomData) {
        _cusTomData = [NSMutableArray array];
        realNameModel *model1 = [realNameModel new];
        model1.title = @"姓    名";
        model1.content = @"请输入您的真实姓名";
        realNameModel *model2 = [realNameModel new];
        model2.title = @"身份证号";
        model2.content = @"请输入您的身份证号";
        realNameModel *model3 = [realNameModel new];
        model3.title = @"选择银行";
        model3.content = @"请选择开户行";
        realNameModel *model4= [realNameModel new];
        model4.title = @"银行卡号";
        model4.content = @"请输入银行卡号";
        realNameModel *model5 = [realNameModel new];
        model5.title = @"手机号码";
        model5.content = @"请输入银行预留手机号";
        [_cusTomData addObjectsFromArray:@[model1, model2, model3, model4, model5]];
    }
    return _cusTomData;
}
- (void)dealloc {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
